/**
 * Created with IntelliJ IDEA.
 * User: info
 * Email: guobin@ebigdata.org
 * Date: 2017/11/21
 * Time: 9:26
 * To change this template use File | Settings | File Templates.
 */
import http from '@http/http'

function servive () {
  let myServices = {}
  /* 获取角色列表 */
  myServices._getRoleList = () => {
    return http.GET('./api/job/list')
  }
  /* 新增角色 */
  myServices._addRole = (data) => {
    return http.POST('./api/job/add', data)
  }
  /* 修改角色 */
  myServices._editRole = (data) => {
    return http.POST('./api/job/edit', data)
  }
  /* 冻结角色 */
  myServices._freezeRole = (data) => {
    return http.POST('./api/job/freeze/' + data)
  }
  /* 解冻角色 */
  myServices._thawRole = (data) => {
    return http.POST('./api/job/thaw/' + data)
  }
  /* 获取角色名单 */
  myServices._getUserByRole = (data) => {
    return http.POST('./api/job/getUsersByJob', data)
  }
  /* 解冻用户 */
  myServices._thawUser = (roleId, userId) => {
    return http.POST('./api/job/thawUser/' + roleId + '/' + userId)
  }
  /* 冻结用户 */
  myServices._freezeUser = (roleId, userId) => {
    return http.POST('./api/job/freezeUser/' + roleId + '/' + userId)
  }
  /* 查询未授权app集合 */
  myServices._getAllApp = () => {
    return http.GET('./api/job/getAllApps')
  }
  /* 授权app */
  myServices._grantApp = (data) => {
    return http.POST('./api/job/grantApp', data)
  }
  /* 删除用户角色 */
  myServices._deleteRole = (roleId, userId) => {
    return http.POST('./api/job/deleteUserRole/' + roleId + '/' + userId)
  }

  // 删除岗位
  myServices._deleteJob = (jobId) => http.DELETE(`./api/job/${jobId}`)
  return myServices
}

export default servive
